package fileDemo.mfile;

import java.io.File;

/**
* @author jie
* @version 创建时间：2018年9月4日 下午4:28:40
 * @Function: 文件位置
* 文件夹操作
*/
public class FileLocation {
	public static void main(String[] args) {
		File file = new File("helloworldFile");
		String currentLocation = getCurrentLocation();
		System.out.println(currentLocation);

	}

	private static String getCurrentLocation() {
		File file = new File("");
		System.out.println(file.isDirectory()+"-"+file.isFile());
		System.out.println("getCurrentLocation== "+file.getAbsoluteFile());
		String cutFileAbsPath = file.getAbsolutePath();
		if (cutFileAbsPath.length()>0 && cutFileAbsPath.contains(File.separator)){
			String substring = cutFileAbsPath.substring(0, cutFileAbsPath.lastIndexOf(File.separator));
			System.out.println("parent== "+substring);
		}
		System.out.println("file"+file.getAbsoluteFile());
		System.out.println(file.getAbsolutePath());
		File parentFile = file.getParentFile();

//		file.get
		if (parentFile!=null && parentFile.exists()){
			System.out.println("parent== "+parentFile.getAbsolutePath());
		}else {
			System.err.println("file.getParentFile()  error ");
		}

		return cutFileAbsPath;
	}


}
